<#include "../common/scripts.html">

<style>

    .border tbody tr td:nth-child(odd) {
        width: 140px;
    }

    .border tbody tr td:nth-child(even) {
        width: 200px;
    }

</style>
<div class="page-content detail-content page-content-main">
    <form action="" method="post" id="updateForm" class="form-horizontal">
        <input type="hidden" name="id" id="id" value="${role.id}" >
        <div class="fh-subtitle">基本信息</div>
        <table class="border" style="width:70%">
            <tr>
                <td><span class="required-flag">*</span>角色名称</td>
                <td style="position: relative;">
                    <input type="text" class="form-control-gx" value="${role.roleName}"
                           name="roleName" maxlength="50" autocomplete="off"/>
                </td>
                <td><span class="required-flag">*</span>角色编号</td>
                <td style="position: relative;">
                    <input type="text" class="form-control-gx" value="${role.roleCode}"
                           name="roleCode" maxlength="50" autocomplete="off" readonly/>
                </td>
            </tr>
            <tr>
                <td>所属应用系统</td>
                <td style="position: relative;text-align: left;" colspan="3">
                    <input type="hidden" id="applicationId" name="applicationId" value="${application.id}" />
                    <input type="text" class="form-control-gx" readonly
                           name="applicationName" id="applicationName" value="${application.applicationName}" maxlength="50" autocomplete="off"/>
                </td>
            </tr>
        </table>

    </form>

    <div class="text-center" style="width: 70%; margin-top: 20px;margin-bottom: 60px; ">
        <span class="model-btn" onclick="submit()" style="width:80px;">保存</span>
    </div>
</div>

<script type="text/javascript">
    function submit() {

        if($("#roleName").val()==""){
            sys.topmsg("角色名称不能为空");
            return;
        }

        $.ajax({
            url : "${ctx}/role/updateRole",
            type : "POST",
            datatype : "json",
            data :$("#updateForm").serialize(),
            success : function(data) {
                if (data.success) {
                    js.showMessage("修改角色成功！","","success",1500)
                    js.closeCurrentTabPage(function(contentWindow){
                        contentWindow.reload();
                    });
                } else {
                    sys.topmsg(data.message);
                }
            },
            error : function(data) {
                js.showMessage("请求异常！","","error",1500)
            }
        });

    }

</script>
